#include <stdio.h>
int main(void) {
// 2d array
int num[3][4] = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
};
int
ROWS = 3,
COLS = 4,
i, j;
// pointer
int *ptr = &num[0][0];
// print the element of the array via pointer ptr
for (i = 0; i < ROWS; i++) {
for (j = 0; j < COLS; j++) {
printf("%d ", *(ptr + i * COLS + j));
}
printf("\n");
}
return 0;
}
arr[i][j] = *(ptr + (i x no_of_cols + j))